package com.lagou.service;

import com.lagou.dao.CodeDao;
import com.lagou.pojo.Code;
import com.laogu.service.ValidateCodeService;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.text.SimpleDateFormat;

/**
 * @Author zhangbbk
 * @Description //TODO
 * @Date 2020/5/16 2:34
 **/
@Service
public class ValidateCodeServiceImpl  implements ValidateCodeService {

    @Autowired
    private CodeDao codeDao;

    @Override
    public String validateCode(String email, String code) {

        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        Code latestCode = codeDao.findLatestCode(email);
        if(latestCode == null) {
            return "1";
        }
/*        long expireTime = Long.parseLong(latestCode.getExpiretime());
        long nowTime = System.currentTimeMillis();
        if(nowTime > expireTime) {
            return "2";
        }*/
        /*
        String long  data 之间的互相转化;
         */
        return "0";
    }
}
